﻿''' <summary>
''' 字符处理方法
''' </summary>
''' <remarks></remarks>
Public Module StringHelper
    ''' <summary>
    ''' 将文档内容放入PL1Source数组
    ''' </summary>
    ''' <param name="Filename"></param>
    ''' <remarks></remarks>
    Sub ReadFileToPL1Source(ByVal Filename As String)
        Dim InputStreamReader As New IO.StreamReader(Filename, Text.Encoding.GetEncoding(932))
        Dim strLine As String
        PL1Source.Clear()
        Do While True
            strLine = InputStreamReader.ReadLine()
            '注意：If strLine <> Nothing Then 这样的写法，如果遇到空行的话，会跳出循环的！
            If (Not strLine Is Nothing) AndAlso strLine <> String.Empty AndAlso (Asc(strLine) <> 26) Then
                PL1Source.Add(strLine)
            Else
                Exit Do
            End If
        Loop
        InputStreamReader.Close()
    End Sub
    ''' <summary>
    ''' 去掉尾部数字,将注释放到最前面
    ''' </summary>
    ''' <remarks></remarks>
    Sub FormatPL1Source()
        Dim EXECIndex As Byte = 1
        EXECList.Clear()
        Dim OrgText As String
        Dim tempText As String
        Dim PL1Comment As New List(Of String)
        '是否在EXEC中
        Dim IsExec As Boolean = False
        'EXEC字符串
        Dim strExec As String = String.Empty
        For i As Integer = 0 To PL1Source.Count - 1
            OrgText = PL1Source(i)
            '去掉尾部数字
            If MyConfig.HasNumberInDoc Then
                OrgText = Mid(OrgText, 2, OrgText.Length - 9).TrimEnd
            Else
                OrgText = Mid(OrgText, 2).TrimEnd
            End If
            Dim BlockCommentStart As Integer
            Dim BlockCommentEnd As Integer
            BlockCommentStart = InStr(OrgText, "/*")
            BlockCommentEnd = InStr(OrgText, "*/")
            If BlockCommentStart > 0 AndAlso BlockCommentEnd > BlockCommentStart Then
                tempText = ClearComment(OrgText)
            Else
                tempText = OrgText
            End If
            '去掉空白字符
            tempText = tempText.Trim
            Select Case True
                Case tempText.StartsWith("%INCLUDE")
                    '对于INCLUDE相关句子，尾部的符号调整
                    '1)INCLUDE AAA;;
                    '2)INCLUDE AAA;
                    '     ;
                    Dim NextScanLine As String = String.Empty
                    '考察下一行是否为单独的；行，对应INCLUDE问题 2）
                    If i + 1 <= PL1Source.Count - 1 Then
                        If MyConfig.HasNumberInDoc Then
                            NextScanLine = Trim(Mid(PL1Source(i + 1), 2, PL1Source(i + 1).Length - 9))
                        Else
                            NextScanLine = Trim(Mid(PL1Source(i + 1), 2))
                        End If
                    End If
                    If NextScanLine = ";" Or NextScanLine = "," Then
                        If tempText.EndsWith(";") Then
                            tempText = Mid(tempText, 1, tempText.Length - 1)
                        End If
                    End If
                    If tempText.EndsWith(";;") Then
                        tempText = Mid(tempText, 1, tempText.Length - 2) & ";"
                    End If
                    If tempText.EndsWith(";,") Then
                        tempText = Mid(tempText, 1, tempText.Length - 2) & ","
                    End If
                    PL1Source(i) = tempText
                Case tempText.StartsWith("EXEC ")
                    'EXEC 命令开始
                    IsExec = True
                    PL1Source(i) = "EXEC_" & EXECIndex & ";"
                    strExec = OrgText & vbCr
                Case Else
                    PL1Source(i) = tempText
                    '如果还在EXEC段中
                    If IsExec Then
                        PL1Source(i) = String.Empty
                        strExec &= OrgText & vbCr
                    End If
            End Select
            '注释
            If BlockCommentStart > 0 Then
                PL1Comment.Add(GetComment(OrgText))
            Else
                PL1Comment.Add(String.Empty)
            End If
            '结束EXEC标志
            If tempText.TrimEnd.EndsWith(";") And IsExec Then
                EXECIndex += 1
                strExec = Mid(strExec, 1, strExec.Length - 2)
                EXECList.Add(strExec)
                IsExec = False
            End If
        Next


        '循环变量
        Dim LoopCount As Integer = 0
        '正在扫描的行
        Dim ScanLine As String = String.Empty
        '已经扫描过的，但是还没有加入列表的内容
        Dim ScanedLine As String = String.Empty
        '临时字符列表
        Dim tempStrList As New List(Of String)
        Do While LoopCount <= PL1Source.Count - 1
            ScanLine = Trim(PL1Source(LoopCount))
            If ScanLine <> String.Empty Then
                Dim orgScanLine As String = ScanLine
                ScanLine = Trim(PL1Comment(LoopCount)) + ScanLine

                '以分号结尾,或者冒号结尾,且下一行不是单独的 “，”
                If (ScanLine.EndsWith(";") Or ScanLine.EndsWith(":")) Then
                    Select Case ScanLine
                        Case ";"
                            '单行分号或者逗号,则并入上面一行
                            ScanedLine += ";"
                            tempStrList.Add(ScanedLine)
                            ScanedLine = String.Empty
                        Case "%PAGE;", "%SKIP;"
                            'TODO: 打印控制符的判断
                        Case Else
                            If Not ScanLine.StartsWith("%SKIP") Then
                                '不是%SKIP的情况
                                Dim AddString As String
                                If ScanedLine.Trim.EndsWith(",") Or _
                                    (Not (ScanedLine.Trim.EndsWith("&") Or ScanedLine.Trim.EndsWith("|")) And _
                                          orgScanLine.Trim.StartsWith("(")) Then
                                    '如果上一行最后以逗号或当前行以左括号开始
                                    AddString = (ScanedLine & ScanLine).Trim
                                Else
                                    AddString = (ScanedLine & Space(1) & ScanLine).Trim
                                End If
                                '一行两句的情况
                                For Each T As String In GetSubLinesBySplitMark(AddString, ";", SplitStyle.WithSplitMark)
                                    If T.Trim = ";" Then
                                        '单行分号,并入上面一行
                                        tempStrList(tempStrList.Count - 1) &= ";"
                                    Else
                                        tempStrList.Add(T.Trim)
                                    End If
                                Next
                                ScanedLine = String.Empty
                            End If
                    End Select
                Else
                    If ScanedLine.Trim.EndsWith(",") Or _
                        (Not (ScanedLine.Trim.EndsWith("&") Or ScanedLine.Trim.EndsWith("|")) And _
                              orgScanLine.Trim.StartsWith("(")) Then
                        '如果上一行最后以逗号或当前行以左括号开始
                        ScanedLine = (ScanedLine & ScanLine).Trim
                    Else
                        ScanedLine = (ScanedLine & Space(1) & ScanLine).Trim
                    End If
                End If
            Else
                'TODO:整行注释和短注释需要区分
                If Trim(PL1Comment(LoopCount)) <> String.Empty Then
                    If ScanedLine <> String.Empty Then
                        ScanedLine += Space(1) & PL1Comment(LoopCount)
                    Else
                        tempStrList.Add(Trim(PL1Comment(LoopCount)))
                    End If
                End If
            End If
            LoopCount += 1
        Loop
        '如果是从Copy句过来的话，可能最后一行没有分号
        '这样的话，需要将最后一句加进来
        'Ref:COPY句的处理思考-2
        If (Not ScanedLine.Trim = String.Empty) Then
            tempStrList.Add(ScanedLine & ";")
        End If
        PL1Source = tempStrList
        If TestMode Then
            Dim T As New IO.StreamWriter("C:\ConversionTool\TestData\TMP\SourceTemp.txt", False, Text.Encoding.GetEncoding("Shift-JIS"))
            For Each Str As String In PL1Source
                T.WriteLine(Str)
            Next
            T.Close()
        End If
    End Sub
    ''' <summary>
    ''' 将/*...*/注释化为 *.....*
    ''' </summary>
    ''' <param name="orgText"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function FormatCOBOLComment(ByVal orgText As String) As String
        Dim rtnString As String = Space(6) & orgText
        Dim iLength As Byte = Text.Encoding.GetEncoding("Shift-JIS").GetByteCount(rtnString)
        If iLength > 72 Then
            '如果字符长度超过72个字节，截取前72个字节
            rtnString = Mid(rtnString, 1, rtnString.Length - (iLength - 72))
        End If
        If Mid(rtnString, rtnString.Length, 1) <> "*" Then
            '如果最后一个字符不为*，则强制将最后一个符号转为*
            rtnString = Mid(rtnString, 1, rtnString.Length - 1) & "*"
        End If
        Return rtnString
    End Function
    ''' <summary>
    ''' 根据分割号划分子句的样式
    ''' </summary>
    ''' <remarks></remarks>
    Enum SplitStyle As Byte
        NoSplitMark = 1
        WithSplitMark = 2
    End Enum
    ''' <summary>
    ''' 根据分割号划分子句
    ''' </summary>
    ''' <param name="StrLine"></param>
    ''' <param name="SplitMark"></param>
    ''' <param name="Style"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function GetSubLinesBySplitMark(ByVal StrLine As String, ByVal SplitMark As Char, ByVal Style As SplitStyle) As List(Of String)
        'Style = 1 的时候，尾部没有分割号，且分割子句的尾部也没有分割号
        'Style = 2 的时候，尾部有分割号，且分割子句的尾部也有分割号
        Dim strRtn As New List(Of String)
        '注意,逗号必须不在 ''  () 里面
        Dim QuoteLV As Byte = 0
        Dim intStart As Integer = 1
        Dim SingleChar As Char = String.Empty
        Dim DoubleChar As String = String.Empty
        Dim QuoteAdd As Boolean = True
        Dim TestInComment As Boolean = False
        For iLength As Integer = 1 To StrLine.Length
            SingleChar = Mid(StrLine, iLength, 1)
            If iLength <> StrLine.Length Then
                DoubleChar = Mid(StrLine, iLength, 2)
                Select Case DoubleChar
                    Case "/*"
                        QuoteLV += 1
                        TestInComment = True
                    Case "*/"
                        QuoteLV -= 1
                        TestInComment = False
                End Select
            End If
            If TestInComment Then Continue For
            Select Case SingleChar
                Case "'"
                    If QuoteAdd Then
                        QuoteLV += 1
                    Else
                        QuoteLV -= 1
                    End If
                    QuoteAdd = Not QuoteAdd
                Case "("
                    If QuoteAdd Then QuoteLV += 1
                Case ")"
                    If QuoteAdd Then QuoteLV -= 1
                Case SplitMark
                    If QuoteLV = 0 Then
                        If Style = SplitStyle.NoSplitMark Then
                            strRtn.Add(Mid(StrLine, intStart, iLength - intStart))
                            intStart = iLength + 1
                        Else
                            If iLength = StrLine.Length Then
                                strRtn.Add(Mid(StrLine, intStart))
                            Else
                                strRtn.Add(Mid(StrLine, intStart, iLength - intStart + 1))
                                intStart = iLength + 1
                            End If
                        End If
                    End If
            End Select
        Next
        If Style = SplitStyle.NoSplitMark Then strRtn.Add(Mid(StrLine, intStart, StrLine.Length - intStart + 1))
        Return strRtn
    End Function
    ''' <summary>
    ''' 获取文法词语列表(文本)
    ''' </summary>
    ''' <param name="CurrentText"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Function GetSyntaxToken(ByVal CurrentText As String) As List(Of String)
        '以空格 = 等于号 >= 大于等于 <=  小于 & 逻辑和 | 逻辑或 做为区分单词,
        '但是如果这个空格在 '' 引号 () 括号 里面的,则不作为区分对象
        'FormatCondition方法严重依赖这个方法,修改以前一定要考虑对这个方法的影响!
        '多个空格的话,则进行合并
        Dim StrWords As New List(Of String)
        '注意,逗号必须不在 '' () 里面
        Dim QuoteLV As Byte = 0
        Dim intStart As Integer = 1
        Dim SingleChar As Char = String.Empty
        Dim QuoteAdd As Boolean = True
        Dim iLength As Integer = 1
        Do While iLength <= CurrentText.Length
            SingleChar = Mid(CurrentText, iLength, 1)
            Select Case SingleChar
                Case "'"
                    If QuoteAdd Then
                        QuoteLV += 1
                    Else
                        QuoteLV -= 1
                    End If
                    QuoteAdd = Not QuoteAdd
                Case "("
                    '如果在括号内,不计算
                    If QuoteAdd Then QuoteLV += 1
                Case ")"
                    '如果在括号内,不计算
                    If QuoteAdd Then QuoteLV -= 1

                    If QuoteLV = 0 Then
                        '以右括号结尾，但是后面没有点号的情况下，这个括号作为一个语法单位
                        '(AAA)(BBB) ->  (AAA)
                        '               (BBB)
                        'T(1).A     ->  T(1).A
                        If iLength <> CurrentText.Length Then
                            If Mid(CurrentText, iLength + 1, 1) <> "." Then
                                StrWords.Add(Mid(CurrentText, intStart, iLength - intStart + 1))
                                intStart = iLength + 1
                            End If
                        End If
                    End If
                Case Space(1)
                    '空格
                    If QuoteLV = 0 Then
                        StrWords.Add(Mid(CurrentText, intStart, iLength - intStart))
                        intStart = iLength + 1
                    End If
                Case ">"
                    '->的组合不算在Token里面
                    If QuoteLV = 0 And Mid(CurrentText, iLength - 1, 1) <> "-" Then
                        If Mid(CurrentText, iLength + 1, 1) = "=" Then
                            StrWords.Add(Mid(CurrentText, intStart, iLength - intStart))
                            StrWords.Add(SingleChar & "=")
                            iLength += 1
                            intStart = iLength + 1
                        Else
                            StrWords.Add(Mid(CurrentText, intStart, iLength - intStart))
                            StrWords.Add(SingleChar)
                            intStart = iLength + 1
                        End If
                    End If
                Case "<"
                    If QuoteLV = 0 Then
                        If Mid(CurrentText, iLength + 1, 1) = "=" Then
                            StrWords.Add(Mid(CurrentText, intStart, iLength - intStart))
                            StrWords.Add(SingleChar & "=")
                            iLength += 1
                            intStart = iLength + 1
                        Else
                            StrWords.Add(Mid(CurrentText, intStart, iLength - intStart))
                            StrWords.Add(SingleChar)
                            intStart = iLength + 1
                        End If
                    End If
                Case "=", "&", "+", "/", "*"
                    '等号,逻辑和
                    If QuoteLV = 0 Then
                        StrWords.Add(Mid(CurrentText, intStart, iLength - intStart))
                        StrWords.Add(SingleChar)
                        intStart = iLength + 1
                    End If
                Case "|"
                    '| 逻辑或符号，因为可能是 || ,所以要考察后一个位置
                    If QuoteLV = 0 Then
                        If Mid(CurrentText, iLength, 2) = "||" Then
                            StrWords.Add(Mid(CurrentText, intStart, iLength - intStart))
                            StrWords.Add("||")
                            iLength += 1
                            intStart = iLength + 1
                        Else
                            StrWords.Add(Mid(CurrentText, intStart, iLength - intStart))
                            StrWords.Add("|")
                            intStart = iLength + 1
                        End If
                    End If
                Case "-"
                    '- 减号符号，因为可能是 -> ,所以要考察后一个位置
                    If QuoteLV = 0 Then
                        '如果不是 -> ,只是 - 的情况，则加入Token，如果是 -> 的情况，不加入
                        If Mid(CurrentText, iLength, 2) <> "->" Then
                            StrWords.Add(Mid(CurrentText, intStart, iLength - intStart))
                            StrWords.Add("-")
                            intStart = iLength + 1
                        End If
                    End If
            End Select
            iLength += 1
        Loop
        If CurrentText.Length - intStart + 1 > 0 Then
            StrWords.Add(Mid(CurrentText, intStart, CurrentText.Length - intStart + 1))
        End If
        Dim RtnWords As New List(Of String)
        For i As Integer = 0 To StrWords.Count - 1
            Dim SingleWord As String = StrWords(i).Trim
            If SingleWord <> String.Empty Then
                RtnWords.Add(StrWords(i).Trim)
            End If
        Next

        Dim NewRtnWords As New List(Of String)
        For i As Integer = 0 To RtnWords.Count - 1
            If i <> RtnWords.Count - 1 AndAlso RtnWords(i + 1) = "->" Then
                NewRtnWords.Add(RtnWords(i) & "->" & RtnWords(i + 2))
                i += 2
            Else
                NewRtnWords.Add(RtnWords(i))
            End If
        Next
        Return NewRtnWords
    End Function
    ''' <summary>
    ''' 是否存在单词以指定关键字开头
    ''' </summary>
    ''' <param name="KeyWord"></param>
    ''' <param name="strWords"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function HasTokenStartWith(ByVal KeyWord As String, ByVal strWords As List(Of String)) As Boolean
        For Each strWord As String In strWords
            If strWord.StartsWith(KeyWord) Then Return True
        Next
        Return False
    End Function
    ''' <summary>
    ''' 是否存在指定关键字
    ''' </summary>
    ''' <param name="KeyWord"></param>
    ''' <param name="strWords"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function HasTOKEN(ByVal KeyWord As String, ByVal strWords As List(Of String)) As Boolean
        For Each strWord As String In strWords
            If strWord = KeyWord Then Return True
        Next
        Return False
    End Function
    ''' <summary>
    ''' 指定关键字的索引
    ''' </summary>
    ''' <param name="KeyWord"></param>
    ''' <param name="strWords"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetTokenPos(ByVal KeyWord As String, ByVal strWords As List(Of String)) As Integer
        For mIndex As Integer = 0 To strWords.Count - 1
            If strWords(mIndex) = KeyWord Then Return mIndex + 1
        Next
    End Function
    ''' <summary>
    ''' 获得属性
    ''' </summary>
    ''' <param name="AttrKey"></param>
    ''' <param name="strWords"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetAttr(ByVal AttrKey As String, ByVal strWords As List(Of String)) As String
        Dim strRtn As String = String.Empty
        For i As Byte = 0 To strWords.Count - 1
            If strWords(i).StartsWith(AttrKey) Then
                If AttrKey = strWords(i) Then
                    'ATTR (AAAA) 也有可能
                    If i <> strWords.Count - 1 Then
                        If (strWords(i + 1).StartsWith("(") And (strWords(i + 1).EndsWith(")"))) Or _
                           (strWords(i + 1).StartsWith("'") And (strWords(i + 1).EndsWith("'"))) Then
                            Return Mid(strWords(i + 1), 2, strWords(i + 1).Length - 2)
                        End If
                    End If
                Else
                    '注意,可能是用 '' 或者 () 来标识属性的!
                    If strWords(i).StartsWith(AttrKey & "(") And (strWords(i).EndsWith(")")) Or _
                       strWords(i).StartsWith(AttrKey & "'") And (strWords(i).EndsWith("'")) Then
                        Return Mid(strWords(i), AttrKey.Length + 2, strWords(i).Length - 2 - AttrKey.Length)
                    End If
                End If
            End If
        Next
        Return strRtn
    End Function
    ''' <summary>
    ''' 是否计算式
    ''' </summary>
    ''' <param name="strtext"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function IsFormulate(ByVal strtext As String) As Boolean
        Dim strWordList As New List(Of String)
        strWordList = GetSyntaxToken(strtext)
        For Each strWord As String In strWordList
            Select Case strWord
                Case "+", "-", "*", "/"
                    If strWordList.Count > 1 Then Return True
            End Select
        Next
    End Function
    ''' <summary>
    ''' 除去注释
    ''' </summary>
    ''' <param name="strtext"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function ClearComment(ByVal strText As String) As String
        Dim strOrgText As String = strText
        Dim SeekStartPostion As Integer = 1
        Dim StartMarkPosition As Integer = 0
        Dim EndMarkPosition As Integer = 0
        'ST-EN位置记录列表
        Dim ST_ENPosList As New List(Of Integer)
        'ST-EN位置的确定
        StartMarkPosition = InStr(SeekStartPostion, strOrgText, "/*")
        EndMarkPosition = InStr(SeekStartPostion, strOrgText, "*/")
        Do While StartMarkPosition + EndMarkPosition <> 0
            '发现ST或者EN
            If StartMarkPosition <> 0 And EndMarkPosition <> 0 Then
                Dim MinPos As Integer = Math.Min(StartMarkPosition, EndMarkPosition)
                ST_ENPosList.Add(MinPos)
                SeekStartPostion = MinPos + 2
            Else
                If StartMarkPosition > 0 Then
                    ST_ENPosList.Add(StartMarkPosition)
                    SeekStartPostion = StartMarkPosition + 2
                Else
                    If EndMarkPosition > 0 Then
                        ST_ENPosList.Add(EndMarkPosition)
                        SeekStartPostion = EndMarkPosition + 2
                    End If
                End If
            End If
            '寻找下一个
            StartMarkPosition = InStr(SeekStartPostion, strOrgText, "/*")
            EndMarkPosition = InStr(SeekStartPostion, strOrgText, "*/")
        Loop
        If ST_ENPosList.Count = 0 Then Return strOrgText
        Dim strRtn As String = String.Empty
        strRtn = Mid(strOrgText, 1, ST_ENPosList(0) - 1)
        For t As Byte = 1 To ST_ENPosList.Count / 2 - 1
            strRtn &= Mid(strOrgText, ST_ENPosList(2 * t - 1) + 2, ST_ENPosList(2 * t) - ST_ENPosList(2 * t - 1) - 2)
        Next
        strRtn &= Mid(strOrgText, ST_ENPosList(ST_ENPosList.Count - 1) + 2)
        Return strRtn
    End Function
    ''' <summary>
    ''' 获得注释
    ''' </summary>
    ''' <param name="strtext"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetComment(ByVal strtext As String) As String
        Dim RtnStr As String = String.Empty
        Dim strOrgText As String = strtext
        Dim SeekStartPostion As Integer = 1
        Dim StartMarkPosition As Integer = 0
        Dim EndMarkPosition As Integer = 0
        'ST-EN位置记录列表
        Dim ST_ENPosList As New List(Of Integer)
        'ST-EN位置的确定
        StartMarkPosition = InStr(SeekStartPostion, strOrgText, "/*")
        EndMarkPosition = InStr(SeekStartPostion, strOrgText, "*/")
        Do While StartMarkPosition + EndMarkPosition <> 0
            '发现ST或者EN
            If StartMarkPosition <> 0 And EndMarkPosition <> 0 Then
                Dim MinPos As Integer = Math.Min(StartMarkPosition, EndMarkPosition)
                ST_ENPosList.Add(MinPos)
                SeekStartPostion = MinPos + 2
            Else
                If StartMarkPosition > 0 Then
                    ST_ENPosList.Add(StartMarkPosition)
                    SeekStartPostion = StartMarkPosition + 2
                Else
                    If EndMarkPosition > 0 Then
                        ST_ENPosList.Add(EndMarkPosition)
                        SeekStartPostion = EndMarkPosition + 2
                    End If
                End If
            End If
            '寻找下一个
            StartMarkPosition = InStr(SeekStartPostion, strOrgText, "/*")
            EndMarkPosition = InStr(SeekStartPostion, strOrgText, "*/")
        Loop
        If ST_ENPosList.Count = 0 Then Return RtnStr
        For t As Byte = 1 To ST_ENPosList.Count / 2
            RtnStr &= Mid(strOrgText, ST_ENPosList(2 * t - 2), ST_ENPosList(2 * t - 1) - ST_ENPosList(2 * t - 2) + 2)
        Next
        Return RtnStr
    End Function
    ''' <summary>
    ''' 获得分行注释
    ''' </summary>
    ''' <param name="strtext"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetCommentArray(ByVal strtext As String) As List(Of String)
        Dim RtnStr As New List(Of String)
        Do While InStr(strtext, "/*") > 0 And InStr(strtext, "*/") > 0
            RtnStr.Add(Mid(strtext, InStr(strtext, "/*"), InStr(strtext, "*/") - InStr(strtext, "/*") + 2))
            strtext = Mid(strtext, 1, InStr(strtext, "/*") - 1) & Mid(strtext, InStr(strtext, "*/") + 2)
        Loop
        Return RtnStr
    End Function
    ''' <summary>
    ''' 获得缩进用空格
    ''' </summary>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetSpace() As String
        Dim spaceNumber As Int16
        spaceNumber = 8 + Deepth * Indent
        If spaceNumber > RightEnd Then
            spaceNumber = LeftStart
        End If
        Return Space(spaceNumber)
    End Function
End Module

